<template>
  <div class="extension">
    <a @click='advertisingPush(index)' v-for="(item,index) in datas">
      <div>
        <img :src="item.src"/>
      </div>
    </a>
  </div>
</template>
<script>
  import {GridsGroup, GridsItem} from 'vue-ydui/dist/lib.rem/grids'
  export default {
    components:{
      'yd-grids-group':GridsGroup,
      'yd-grids-item':GridsItem
    },
    data(){
      return {
        datas:[
//          {src:require('components/img/thumb_raw_1510990121.png'),id:'001'},
//          {src:require('components/img/thumb_raw_1510990121.png'),id:'002'},
//          {src:require('components/img/thumb_raw_1510990121.png'),id:'003'},
//          {src:require('components/img/thumb_raw_1510990121.png'),id:'004'},
//          {src:require('components/img/thumb_raw_1510990121.png'),id:'005'},
//          {src:require('components/img/thumb_raw_1510990121.png'),id:'006'}
        ],
        center: {
          lng: 104.188148,
          lat: 30.568834
        },
      }
    },
    methods:{
      advertisingPush(n){
        this.$router.push({path:'/chat/advertisingPush',query:{id:this.datas[n]}})
      },
      http: function () {
        this.ylAjax.aroundCards(this.center).then(msg=>{
          for(var i=0;i<msg.data.length;i++){
            msg.data[i].src = this.$store.state.ip+msg.data[i].cardPic
          }
          this.$store.commit("issueContent",msg.data);
          this.datas = this.$store.state.issueContent
        })

      },
      location: function () {
        this.$GPS
        this.center.lng = this.$store.state.locations.lng;
        this.center.lat = this.$store.state.locations.lat;
      }
    },
    activated(){
      window.time = setInterval(this.location,500);
      setTimeout(this.http,550);
      window.times = setTimeout(this.http,10000);


    },
    deactivated(){
      clearInterval(window.time)
    }
  }

</script>
<style lang="less" scoped>
  @import "~less/base";
  .extension{
    >a{
      >div{
        width: 25%;
        height: 1.055rem;
        box-sizing: border-box;
        border: 1px solid white;
        float: left;
        >img{
          width: 100%;
          height: 100%;
        }
      }
    }
  }
</style>
